package com.itheima.health.dao;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import java.time.LocalDate;
import com.itheima.health.pojo.Member;
import org.apache.ibatis.annotations.Options;


/**
 * @author 张博源
 * @date 2024-04-16
 */
@Mapper
public interface MemberDao {
    Integer selectMemberCount(LocalDate start, LocalDate stop);

    @Select("select count(*) from t_member where phoneNumber = #{phoneNumber}")
    Integer selectByphoneNumber(@Param("phoneNumber") String phoneNumber);
    @Insert("insert into t_member(phoneNumber) value (#{phoneNumber})")
    void insertMember(String telephone);

    /**
     * 根据phoneNumber查询是否是会员
     */

    //@Options(useGeneratedKeys = true,keyProperty = "id")
    @Select("select * from t_member where phoneNumber = #{phoneNumber}")
    Member select(@Param("phoneNumber") String phoneNumber);

    /**
     * 如果是会员就更新
     */
    void update(Member member);

    /**
     * 新增会员
     */
    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert(" insert into t_member(fileNumber, name, sex, idCard, phoneNumber, regTime, password, email, birthday, remark) values (#{fileNumber},#{name},#{sex},#{idCard},#{phoneNumber},#{regTime},#{password},#{email},#{birthday},#{remark}) ")
    void insert(Member member);

    /**
     * 根据id查询
     */
    @Select("select * from t_member where id = #{id}")
    Member selectById(Integer id);
}




